package cn.tedu.rabbitmqspringboot.m2;

import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class Main {
    @Autowired
    private Producer p;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Bean
    public Queue taskQueue() {
        return new Queue("task_queue"); //true,false,false
    }

    @PostConstruct
    public void test() {
         // new Thread(new Runnable() {
         //     @Override
         //     public void run() {
         //         p.send();
         //     }
         // }).start();

         new Thread(() -> p.send()).start();
    }


}







